package com.clss.emergencycall.bean;

import androidx.annotation.NonNull;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;

import java.io.Serializable;

/** 从NewMessageBean转换过来的，保存数据库时用的，其中body只能为字符串类型 */

@Entity(tableName = "msgLog")
public class DeviceEvent implements Serializable{
	@PrimaryKey
	@ColumnInfo(name = "msg_id")
	@NonNull
	private String id;

	@ColumnInfo(name = "msg_type")
	private String event;

	@ColumnInfo(name = "msg_body")
	private String body;

	@ColumnInfo(name = "msg_from")
	private String from;

	@ColumnInfo(name = "msg_time")
	private String time = "";

	@ColumnInfo(name = "msg_receiver")
	private String receiver = "";

	@ColumnInfo(name = "notify_id")
	private int notifyId = -1;

	@ColumnInfo(name = "click_count")
	private int clickCount = 0;

	@ColumnInfo(name = "msg_origin")
	private String origin;

	@ColumnInfo(name = "msg_subject")
	private String subject;

	@ColumnInfo(name = "msg_text")
	private String text;

	public String getEvent() {
		return event;
	}

	public void setEvent(String event) {
		this.event = event;
	}

//	public void setBodyProduct(JsonElement bodyProduct) {
//		this.bodyProduct = bodyProduct;
//	}
//
//	public JsonElement getBodyJsonElement() {
//		if (bodyProduct == null){
//			try {
//				JSONObject jsonObject = new JSONObject(body);
//				bodyProduct = new Gson().fromJson(jsonObject.toString(), JsonElement.class);
//			} catch (JSONException e) {
//				e.printStackTrace();
//				return bodyProduct;
//			}
//		}
//		return bodyProduct;
//	}

	public String getFrom() {
		return from;
	}

	public void setFrom(String from) {
		this.from = from;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public int getNotifyId() {
		return notifyId;
	}

	public void setNotifyId(int notifyId) {
		this.notifyId = notifyId;
	}

	public int getClickCount() {
		return clickCount;
	}

	public void setClickCount(int clickCount) {
		this.clickCount = clickCount;
	}

	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}

	public String getReceiver() {
		return receiver;
	}

	public void setReceiver(String receiver) {
		this.receiver = receiver;
	}

	public String getOrigin() {
		return origin;
	}

	public void setOrigin(String origin) {
		this.origin = origin;
	}

	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	@Override
	public String toString() {
		return "DeviceEvent{" +
				"id='" + id + '\'' +
				", event='" + event + '\'' +
				", body='" + body + '\'' +
				", from='" + from + '\'' +
				", time='" + time + '\'' +
				", receiver='" + receiver + '\'' +
				", notifyId=" + notifyId +
				", clickCount=" + clickCount +
				", origin='" + origin + '\'' +
				", subject='" + subject + '\'' +
				", text='" + text + '\'' +
//				", bodyProduct=" + bodyProduct +
				'}';
	}
}
